package com.ch04.config;

import com.ch04.web.filter.Filter1;
import com.ch04.web.filter.Filter2;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Jane
 * @date 2024-05-29 16:35
 */

@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean<Filter1> filter(){
        FilterRegistrationBean bean=new FilterRegistrationBean();

        bean.setFilter(new Filter1());
        bean.setName("zhangchangFilter");
        bean.setOrder(Integer.MIN_VALUE);
        bean.addUrlPatterns(new String[]{"/backend/login"});

        return bean;
    }

    @Bean
    public FilterRegistrationBean<Filter2> filter2(){
        FilterRegistrationBean bean=new FilterRegistrationBean();

        bean.setFilter(new Filter2());
        bean.setName("lixuesenFilter2");
        bean.setOrder(Integer.MAX_VALUE);
        bean.addUrlPatterns(new String[]{"/backend/*"});

        return bean;
    }
}
